package com.wnhoo.smartfishtank.util;

import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * Created by kevinwen on 2015/1/21.
 * Copyright (c) 2015/1/21.KevinWen. All rights reserved.
 */
public class TimestampUtil {

    public static final String FORMAT = "yyyy-MM-dd HH:mm:ss";
    public static long toTimeMillis(String data){
        try{
            SimpleDateFormat sdf1 = new SimpleDateFormat(FORMAT);
            Date date = sdf1.parse(data);//提取格式中的日期
            return date.getTime();
        }catch (Exception e){
            e.printStackTrace();
            return 0;
        }
    }

    public static String toTimeDate(long millis){

        String timestamp_value = new SimpleDateFormat(FORMAT).format(new Date(millis));
        return timestamp_value;
    }

}
